package com.yupi.usercenter.Job;

import com.yupi.usercenter.service.MonitorService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class Task {
    @Resource
    private MonitorService monitorService;

    private volatile boolean tasksEnabled = false;

    @Scheduled(fixedRate = 5000)
    public void task(){
        if (tasksEnabled) {
        monitorService.CPUState();

        }
    }

    public void setTasksEnabled(boolean tasksEnabled) {
        this.tasksEnabled = tasksEnabled;
    }

}
